package com.tlcx.kfip.ui;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;

import com.tlcx.kfip.R;
import com.tlcx.kfip.listener.OnClickMenuListener;

import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by victor on 2016/10/28 10:43.
 * Email:zhuzhaoyang@yuanchuangyun.com
 */

public class KfipMenuView extends LinearLayout {

    private Context mContext;
    private LayoutInflater mInflater;
    private OnClickMenuListener clickMenuListener;

    public KfipMenuView(Context context) {
        super(context);
        init(context);
    }

    public KfipMenuView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public KfipMenuView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }
    private void init(Context context){
        mContext = context;
        mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = mInflater.inflate(R.layout.widget_kfip_menu,null,false);
        addView(view);
        ButterKnife.bind(this,view);
    }
    /**
     * 跳转分类
     */
    @OnClick(R.id.ly_kfip_menu_category)
    void skipToCategory(){
        if (clickMenuListener != null) {
            clickMenuListener.onClick(0);
        }
    }

    /**
     * 跳转到秒开专区
     */
    @OnClick(R.id.ly_kfip_menu_second_open)
    void skipToSecondOpen(){
        if (clickMenuListener != null) {
            clickMenuListener.onClick(1);
        }
    }

    /**
     * 跳转晒单
     */
    @OnClick(R.id.ly_kfip_menu_open_bill)
    void skipToOpenBill(){
        if (clickMenuListener != null) {
            clickMenuListener.onClick(2);
        }
    }

    /**
     * 跳转到活动页
     */
    @OnClick(R.id.ly_kfip_menu_activity)
    void skipToActivity(){
        if (clickMenuListener != null) {
            clickMenuListener.onClick(3);
        }
    }

    public void setClickMenuListener(OnClickMenuListener clickMenuListener) {
        this.clickMenuListener = clickMenuListener;
    }
}
